// uploadWorker.js
self.onmessage = function(e) {
    const { fileChunk, uploadUrl } = e.data;
    // 处理文件上传逻辑
    uploadFileChunk(fileChunk, uploadUrl);
  };
  
  function uploadFileChunk(chunk, url) {
    // 使用Fetch API或XMLHttpRequest上传文件片段
    fetch(url, {
      method: 'POST',
      body: chunk,
    }).then(response => {
      return response.json();
    }).then(data => {
      self.postMessage({ status: 'uploaded', data: data });
    }).catch(error => {
      self.postMessage({ status: 'error', error: error });
    });

    Promise.all(chunk).then(res => {
      fetch('http://127.0.0.1:3000/merge', {
          method: 'POST',
          headers: {
              'Content-Type': 'application/json'
          },
          body: JSON.stringify({
              fileName: '大文件',
          })
      }).then(res => {
          console.log(res)
      })
  })
  }
  